/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package util;

/**
 *
 * @author usuario
 */
import java.io.File;
import javax.swing.filechooser.FileFilter;


/**
 * @author wolf
 */
public class TXTFilter extends FileFilter implements java.io.FileFilter {
    String[] extensions;
    String description;

    public TXTFilter(String extension, String description) {
        this.extensions = new String[] { extension };
        this.description = description;
    }

    public TXTFilter(String[] extensions, String description) {
        this.extensions = extensions;
        this.description = description;
    }

    /**
     * @see javax.swing.filechooser.FileFilter#accept(java.io.File)
     */
    public boolean accept(File f) {
    if (f.isDirectory())
      return true;
    String s = f.getName();
    int i = s.lastIndexOf('.');

    if (i > 0 && i < s.length() - 1)
      if (s.substring(i + 1).toLowerCase().equals("txt"))
        return true;

    return false;
  }

  public String getDescription() {
    return "Accepts txt files only.";
  }
}



